module type VM = sig
   type t
   val succl : t -> int
   val color : t -> int
end

module Sort (VT : VM) = struct

let eq_int a b = 
    if a == b
    then 0
    else if a < b 
         then -1
         else 1

let compare_by_val elt1 elt2 = eq_int (List.length elt2) (List.length elt1)

let compare_by_color elt1 elt2 = eq_int  (VT.color elt2) (VT.color elt1)

let compare_by_degree elt1 elt2 = 
    let get_degree elt = List.fold_left (fun d v -> d + (VT.succl v)) 0 elt in
    eq_int (get_degree elt2) (get_degree elt1)

end